#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while (n -- )
    {
        int a,b;
        cin>>a>>b;
        cout<< _gcd(a,b)<<endl;
    }
    return 0;
}
